package com.car.action.admin;

import java.util.List;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;

import com.car.common.model.CardDiscuss;
import com.car.common.model.MessageUnreadNum;
import com.car.common.model.Prop;
import com.car.common.model.PropRecord;
import com.car.common.model.Resume;
import com.car.common.model.UserFriends;
import com.car.common.model.UserRename;
import com.car.common.model.Users;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.utils.PicUtil;
import com.utils.StringUtil;
import com.utils.SystemClock;

public class CertController  extends Controller  {

	public void index() {
		// 1 审核通过 2审核中 3审核失败
		int status = 0;
		if (StringUtil.empty(getPara("status"))) {
			status = 2;
		} else {
			status = getParaToInt("status");
		}
		int page = 1;
		if (!StringUtil.empty(getPara("page"))) {
			page = getParaToInt("page");
		}
		String sql = "select a.user_id,a.id,a.status,a.name,a.code,a.create_time,a.remark,a.id_img_1,a.id_img_2,a.id_img_3,b.nick_name,b.user_mobile,FROM_UNIXTIME(a.create_time,'%Y-%m-%d %H:%i') as create_time_string ";
		String andSql = "from user_rename as a LEFT JOIN users b on b.id = a.user_id  where a.status = " + status + " order by a.id desc ";
		Page<UserRename> pageData = UserRename.dao.paginate(page, 15, sql,andSql);
		
		setAttr("page", pageData);
		
		setAttr("status", getPara("status"));
		render("index.html");
	}
	
	public void detail() {
		setAttr("one", UserRename.dao.findById(getPara("id")));
		render("detail.html");
	}
	
	public void save() {
		UserRename one = UserRename.dao.findById(getPara("id"));
		int status = getParaToInt("status");
		one.setStatus(status);
		one.setRemark(getPara("remark"));
		if (status == 1) {
			Db.update("update users set is_real_name = 1 where id = " + one.getUserId());
		}
		one.update();
		renderText("操作成功!");
	}
}
